package com.yz.pay.utils;

import com.alipay.api.AlipayConfig;
import com.yz.pay.properties.AliPayProperties;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * <p>
 * User:Mr.Du
 * Date:2024/4/21
 * Time:23:15
 */
@Component
@RequiredArgsConstructor
public class AlipayUtils {

    private final AliPayProperties aliPayProperties;

    public AlipayConfig getAlipayConfig() {
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl(aliPayProperties.getGatewayUrl());
        alipayConfig.setAlipayPublicKey(aliPayProperties.getPublicKey());
        alipayConfig.setPrivateKey(aliPayProperties.getPrivateKey());
        alipayConfig.setAppId(aliPayProperties.getAppId());
        alipayConfig.setFormat(aliPayProperties.getFormat());
        alipayConfig.setCharset(aliPayProperties.getCharset());
        alipayConfig.setSignType(aliPayProperties.getSignType());
        return alipayConfig;
    }
}
